-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reduce memory usage of Scope.t #67
Conversation
09ca2dd
to
c94c074
Compare
@@ -845,15 +919,19 @@ module Scope = struct | |||
call it if there is an instrumentation backend. *) | |||
let[@inline] add_attrs (scope : t) (attrs : unit -> key_value list) : unit = | |||
if Collector.has_backend () then | |||
scope.attrs <- List.rev_append (attrs ()) scope.attrs | |||
scope.items <- | |||
List.fold_left (fun acc attr -> Attr (attr, acc)) scope.items (attrs ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think about the order; does it matter ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should matter, no :)
c94c074
to
ac1a27e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, that's exactly what I had in mind!
@@ -845,15 +919,19 @@ module Scope = struct | |||
call it if there is an instrumentation backend. *) | |||
let[@inline] add_attrs (scope : t) (attrs : unit -> key_value list) : unit = | |||
if Collector.has_backend () then | |||
scope.attrs <- List.rev_append (attrs ()) scope.attrs | |||
scope.items <- | |||
List.fold_left (fun acc attr -> Attr (attr, acc)) scope.items (attrs ()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it should matter, no :)
This is my take at implementing your suggestion to reduce
Scope.t
memory usage